#include "ADUBasin.h"


Basin* Basin::CreateBasin(){
	Basin* basin = new Basin();

    if (basin && basin->initWithFile(mPath)) {
    	basin->autorelease();
    	basin->setUp = true;
        return basin;
    }

    CC_SAFE_DELETE(basin);

	return NULL;
}

void Basin::setPosition(const Vec2& pos) {
	Sprite::setPosition(pos);
	if (setUp) {
		setUp = false;
		b2BodyDef _boxBodyDef;
		_boxBodyDef.userData = this;
		_boxBodyDef.type = b2_dynamicBody;
		_boxBodyDef.position.Set(pos.x / PTM_RATIO, pos.y / PTM_RATIO);
		mBody = GameManager::getInstance()->mWorld->CreateBody(&_boxBodyDef);

		b2CircleShape shape;
		shape.m_radius = 130.0f / PTM_RATIO;

		b2FixtureDef boxShapedef;
		boxShapedef.shape = &shape;
		boxShapedef.density = 2.8f;
		boxShapedef.restitution = 0.2f;
		boxShapedef.friction = 1.0f;

		b2Fixture* boxFixture;
		boxFixture = mBody->CreateFixture(&boxShapedef);
	}else{
		mBody->SetTransform(pos.x/PTM_RATIO,pos.y/PTM_RATIO,mBody->GetAngle());
	}
}
